package com.zhangxin.designmode.designpattern.factory.v4;

/**
 * @author zhangxin
 * @date 2022/4/26
 */
public class RuleConfigSource {

    public RuleConfig load(String ruleConfigFilePath) throws Exception {
        String ruleConfigFileExtension = getFileExtension(ruleConfigFilePath);
        IRuleConfigParser parser = RuleConfigParserFactory.createParser(ruleConfigFileExtension);

        String configText = "";
        //从ruleConfigFilePath文件中读取配置文本到configText中
        RuleConfig ruleConfig = parser.parse(configText);
        return ruleConfig;
    }

    private String getFileExtension(String ruleConfigFilePath) {
        //解析文件名获取扩展名，比如rule.json返回json
        return "json";
    }
}
